package com.msconfig.mvp.view.adapter;

/*
 * author: caojunhao
 * date  : 2020/5/11
 * desc  :
 */

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.geo.msconfig.R;

import java.util.ArrayList;

public class DebugCommandsAdapter extends BaseAdapter {
    private Context mContext;
    private ArrayList<String> mList;
    private int mCurrentItem=0;
    private boolean mIsClick =false;

    public DebugCommandsAdapter(Context context, ArrayList<String> list){
       mContext= context;
       mList=list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView==null){
            convertView= LayoutInflater.from(mContext).inflate(R.layout.layout_fragment_setup_ellipsoid_item,parent,false);
            viewHolder=new ViewHolder();
            viewHolder.name=(TextView) convertView.findViewById(R.id.tv_name);
            viewHolder.checkBox=(CheckBox) convertView.findViewById(R.id.checkbox);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
//        viewHolder.checkBox.setChecked(false);
//        if (mCurrentItem==position&& mIsClick){
//            viewHolder.checkBox.setChecked(true);
//        }
        viewHolder.name.setText(mList.get(position));

        return convertView;
    }

    public class ViewHolder{
        TextView name;
        CheckBox checkBox;
    }

    public void setCurrentItem(int currentItem){
        this.mCurrentItem=currentItem;
    }

    public void setmIsClick(boolean mIsClick){
        this.mIsClick = mIsClick;
    }
}


